
## Installation
if(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_SOURCE_DIR})
    ## Main application
    install(TARGETS ${TOP_PROJECT_NAME}
        BUNDLE DESTINATION .
        RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
        LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
    )
    ## Desktops
    configure_file(${CMAKE_SOURCE_DIR}/assets/${TOP_PROJECT_NAME}.desktop.in ${CMAKE_BINARY_DIR}/${TOP_PROJECT_NAME}.desktop @ONLY)
    install(FILES ${CMAKE_BINARY_DIR}/${TOP_PROJECT_NAME}.desktop
        DESTINATION ${INSTALL_DESKTOP_DIR}
    )
    ## Icons
    install(FILES ${CMAKE_SOURCE_DIR}/assets/${TOP_PROJECT_NAME}.svg
        DESTINATION ${INSTALL_ICONS_DIR}
    )
else()
    ## Plugins
    install(TARGETS ${PROJECT_NAME}
        LIBRARY DESTINATION ${INSTALL_PLUGINS_DIR}
    )
endif()

## RPATH
# file(RELATIVE_PATH _rel ${CMAKE_INSTALL_PREFIX}/${INSTALL_BINDIR} ${CMAKE_INSTALL_PREFIX})
# if(APPLE)
#     set(_rpath "@loader_path/${_rel}")
# else()
#     set(_rpath "\$ORIGIN/${_rel}")
# endif()
# file(TO_NATIVE_PATH "${_rpath}/${INSTALL_LIBDIR}" APP_RPATH)
# set_target_properties(${TOP_PROJECT_NAME} PROPERTIES
#     MACOSX_RPATH ON
#     SKIP_BUILD_RPATH OFF                #告诉CMake生成适当的 RPATH ，以便能够在构建树中运行可执行文件。
#     BUILD_WITH_INSTALL_RPATH OFF        #关闭生成可执行目标，使其 RPATH 调整为与安装树的 RPATH 相同。在构建树中不运行可执行文件。
#     INSTALL_RPATH "${APP_RPATH}"        #将已安装的可执行目标的 RPATH 设置为先前的路径。
#     INSTALL_RPATH_USE_LINK_PATH ON      #告诉CMake将链接器搜索路径附加到可执行文件的 RPATH 中。
# )
